require 'MVVM.Sources.View.Adaptor'

ProgressBarAdaptor = class('ProgressBarAdaptor',Adaptor)

function ProgressBarAdaptor:ctor(gameObject, propertyName, binder,func,doanimation)
    self.component = gameObject:GetComponent('Slider')
    self.func = func
    self.doAnimation = doanimation
    self:BindProperty(propertyName, binder)
end


function ProgressBarAdaptor:OnViewModelValueChanged(oldValue, newValue)
    if self.func == nil then
        if self.doAnimation then
            self.component:DOValue(newValue,0.5)
        else
            self.component.value = newValue
        end
    else
        self.component.value = self.func(newValue)
    end
end